﻿using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

///<summary>
///SoldierChaseState追击状态类
///</summary>
class SoldierChaseState:ISoldierState
{
    public override void Reason(List<ICharacter> targets)
    {
        if (targets==null&& targets.Count == 0)
        {
            mFsm.PerformTransition(SoldierTransition.NoEnemy);return;
        }
        float distance = Vector3.Distance(targets[0].Position,mCharacter.Position);
        if (distance<=mCharacter.atkRange)
        {
            mFsm.PerformTransition(SoldierTransition.CanAttack);  
        }
    }

    public override void Act(List<ICharacter> targets)
    {
        //移动到敌人位置
        if (targets!= null && targets.Count>0)
        {
            mCharacter.MoveTo(targets[0].Position);
        }
    }

    public SoldierChaseState(SoldierFSMSystem fsm, ICharacter c) : base(fsm, c)
    {
        mStateID = SoldierStateID.Chase;
    }
}

